<template>
	<div class="user-setting">
		<div class="com-header border-1px">
			<div class="back"
				onclick="javascript:history.go(-1)"
			>
				<i class="iconfont">&#xe697;</i>
			</div>
			<div class="content">
				设置
			</div>
		</div>
		<div class="us-content">
			<div class="us-item border-1px"
				@click="goChange()"
			>
				<p>修改密码</p>
				<i class="iconfont">&#xe6a7;</i>
			</div>
			<div class="logout"
				@click="logout()"
				v-if="wx_index_login == 0"
			>
				<p>退出登录</p>
			</div>
		</div>
	</div>
</template>
<script>
	import { Toast } from 'mint-ui'
	import axios from 'axios'
	import Http from '../http.js'
	import * as types from '../store/types.js' 
	export default{
		data(){
			return{
				wx_index_login: window.localStorage.getItem("wx_index_login"),
			}
		},
		methods: {
			logout: function(){
				localStorage.removeItem("token");
				this.$store.commit(types.LOGOUT);
	            this.$router.push('/')
	            axios.post(Http.Logout).then( res => {
	            	var ret = res.data;
	            	if (ret.code == 1) {
	            		Toast(ret.msg)
	            	}
	            })
			},
			goChange: function(){
				this.$router.push('/user/change/password')
			}
		}
	}
</script>
<style lang="scss" scoped>
	.user-setting{
		.us-content{
			width: 100%;
			min-height: 11.2rem;
			background: #f5f5f5;
			.us-item{
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 4%;
				width: 92%;
				height: 0.88rem;
				line-height: 0.88rem;
				background: #fff;
				font-size: 0.26rem;
				i{
					font-size: 0.44rem;
				}
			}
			.logout{
				margin-top: 0.2rem;
				height: 0.88rem;
				line-height: 0.88rem;
				background: #fff;
				font-size: 0.28rem;
			}
		}
	}
</style>